<template>
  <div>
    <el-form ref="form" size="mini">
      <el-form-item label="启用禁止作答区" :label-width="formLabelWidth">
        <el-switch v-model="forbid"/>
      </el-form-item>
      <el-form-item label="启用AB卷" :label-width="formLabelWidth">
        <el-switch v-model="ab"/>
      </el-form-item>
      <el-form-item label="启用页脚" :label-width="formLabelWidth">
        <el-switch v-model="pageFoot"/>
      </el-form-item>
      <el-form-item
        v-if="pageFoot"
        :label-width="formLabelWidth"
        label="页脚模板">
        <el-input
          v-model="pageFootTpl"
          placeholder="$0是页码占位符号"/>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
  data() {
    return {
      formLabelWidth: '80',

      forbid: true,
      ab: true,
      pageFoot: false,
      pageFootTpl: '',
    };
  },
  computed: {
    ...mapState([
      'enableForbid',
      'enableAB',
      'enablePageFoot',
      'pageFootTemplate',
    ]),
  },
  watch: {
    enableForbid(val) {
      this.forbid = val;
    },
    enableAB(val) {
      this.ab = val;
    },
    enablePageFoot(val) {
      this.pageFoot = val;
    },
    forbid(val) {
      this.updateForbidEnable(val);
    },
    ab(val) {
      this.updateABEnable(val);
    },
    pageFoot(val) {
      this.updatePageFootEnable(val);
    },
    pageFootTpl(val) {
      this.updatePageFootTemplate(val);
    },
  },
  created() {
    this.forbid = this.enableForbid;
    this.ab = this.enableAB;
    this.pageFoot = this.enablePageFoot;
    this.pageFootTpl = this.pageFootTemplate;
  },
  methods: {
    ...mapMutations([
      'updateForbidEnable',
      'updateABEnable',
      'updatePageFootEnable',
      'updatePageFootTemplate',
    ]),
  },
};
</script>

<style lang="less" scoped>

</style>
